package com.shine.chemicalWholeProcessSystem.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.shine.chemicalWholeProcessSystem.BR;
import com.shine.chemicalWholeProcessSystem.R;
import com.shine.chemicalWholeProcessSystem.base.BaseFragment;
import com.shine.chemicalWholeProcessSystem.bean.BaseBean;
import com.shine.chemicalWholeProcessSystem.databinding.FragmentSearchChild1Binding;
import com.shine.chemicalWholeProcessSystem.databinding.FragmentSearchChild3Binding;
import com.shine.chemicalWholeProcessSystem.ui.adapter.SwipeDeleteAdapter;
import com.shine.chemicalWholeProcessSystem.ui.fragment.viewModel.SearchChild1ViewModel;

import java.util.ArrayList;
import java.util.List;

import cn.bingoogolapple.baseadapter.BGADivider;

public class SearchChild3Fragment extends BaseFragment<FragmentSearchChild3Binding, SearchChild1ViewModel> {

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_search_child3;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public SearchChild1ViewModel initViewModel() {
        return new SearchChild1ViewModel(getActivity());
    }

    @Override
    public void initData() {
        super.initData();

        SwipeDeleteAdapter swipeDeleteAdapter = new SwipeDeleteAdapter(binding.recyclerView);
        binding.recyclerView.setAdapter(swipeDeleteAdapter);
        binding.recyclerView.addItemDecoration(BGADivider.newBitmapDivider());
        binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                if (RecyclerView.SCROLL_STATE_DRAGGING == newState) {
                    swipeDeleteAdapter.closeOpenedSwipeItemLayoutWithAnim();
                }
            }
        });


        List<BaseBean> baseBeans = new ArrayList<>();
        BaseBean baseBean = new BaseBean();
        baseBean.setText1("123");
        baseBean.setText2("456");
        baseBeans.add(baseBean);
        baseBeans.add(baseBean);
        baseBeans.add(baseBean);
        baseBeans.add(baseBean);
        swipeDeleteAdapter.setData(baseBeans);
    }


    @Override
    public void onClick(View view) {

    }
}